- Published on
Upgrading AWS Lambda to Node@18 Runtime Checklist
- Authors
- Name
- Gatik Rajput
Upgrading AWS Lambda to Node@18 Runtime Checklist
So you have AWS Lambda in production, using Node.js 14 or 16, and you're looking to upgrade to the new Node@18 Runtimes? Here’s a step-by-step checklist to guide you through the process:
Objective
We aim to provide readers with a clear checklist for upgrading their AWS Lambda functions to the Node@18 runtime.
Checklist
Upgrade Your Local NodeJS Runtime
- Upgrade to Node.js version 18, either by downloading directly from nodejs.org or using nvm. As of the time of writing, Node.js 18.14.2 is the LTS version.
Update package-lock.json
- Run
npm install
to ensure yourpackage-lock.json
reflects the new Node.js version.
- Run
Add Engines Field to package.json
- Add an
engines
field to yourpackage.json
to enforce the use of Node.js 18 for your project.
"engines": { "node": ">=18.14.2" }
- Add an
Update AWS Lambda Configuration
- Modify your AWS Lambda configuration to use the
nodejs18.x
runtime. If using CloudFormation, update"Runtime": "nodejs18.x"
.
- Modify your AWS Lambda configuration to use the
Update CI/CD Pipelines
- Adjust your CI/CD pipelines to build with Node.js version 18.14.2.
Webpack Considerations
- If using Webpack, ensure compatibility with Node@18. Using webpack 5.75 has been found effective for projects targeting Node@18.
Upgrade aws-sdk to Version 3 (Optional but recommended)
- Consider upgrading from aws-sdk v2 to v3, which comes built-in with the AWS Lambda
nodejs18.x
runtime (version 3.188.0). Search for@aws-sdk/client-
on npm to find v3 packages.
{ externals: { "@aws-sdk/client-ses": "@aws-sdk/client-ses" } }
- Consider upgrading from aws-sdk v2 to v3, which comes built-in with the AWS Lambda
Staying with aws-sdk V2
- If you choose to stay with aws-sdk v2, you should bundle it with your code to ensure compatibility with your AWS Lambda function.
End-to-End Testing
- After upgrading and deploying your AWS Lambda function with Node@18, perform comprehensive end-to-end testing to verify functionality and ensure no issues arise.
By following this checklist, you can successfully upgrade your AWS Lambda functions to utilize the latest Node@18 runtime, leveraging enhanced features and performance improvements while ensuring smooth operation in production.